package math;

/**
 * Created by fengliejv on 2017/12/22.
 */
public class NimGame292 {
    //感觉这个动态规划才不是仙术，但是超时
    public boolean canWinNim(int n) {
        if(n<4){
            return true;
        }
        boolean first = true;
        boolean second = true;
        boolean third = true;
        for (int i = 4; i < n+1; i++) {
            boolean temp = !first || !second ||!third;
            first = second;
            second =third;
            third = temp;
        }
        return third;
    }

    public boolean canWinNim1(int n) {
        return n % 4 != 0 ;
    }
}
